

function UdkpOptions_OnLoad()
	UIPanelWindows['UdkpOptionsFrame'] = {area = 'center', pushable = 0};
end

function UdkpOptions_Init()
	UdkpOptionsFrameToggleButton:SetChecked(UdkpOptions.UdkpButtonShown);
	UdkpButtonPos:SetValue(UdkpOptions.UdkpButtonPosition);
end


function UdkpButton_OnClick()
	udkp_dkp_show();
end

function UdkpButton_Init()
	if(UdkpOptions.UdkpButtonShown) then
		UdkpButtonFrame:Show();
	else
		UdkpButtonFrame:Hide();
	end
end

function UdkpButton_Toggle()
	if(UdkpButtonFrame:IsVisible()) then
		UdkpButtonFrame:Hide();
		UdkpOptions.UdkpButtonShown = false;
	else
		UdkpButtonFrame:Show();
		UdkpOptions.UdkpButtonShown = true;
	end
	UdkpOptions_Init();
end

function UdkpButton_UpdatePosition()
	UdkpButtonFrame:SetPoint(
		"TOPLEFT",
		"Minimap",
		"TOPLEFT",
		54 - (78 * cos(UdkpOptions.UdkpButtonPosition)),
		(78 * sin(UdkpOptions.UdkpButtonPosition)) - 55
	);
end


function Udkp_BrowseDropDown_OnLoad()
	UIDropDownMenu_Initialize(this, Udkp_BrowseDropDown_Initialize);
	if(UdkpOptions.ItemQuality) then
		UIDropDownMenu_SetSelectedValue(Udkp_BrowseDropDown, UdkpOptions.ItemQuality);
	end
end


function Udkp_BrowseDropDown_Initialize()
	info = {};
	info.text = ALL;
	info.value = -1;
	info.func = Udkp_BrowseDropDown_OnClick;
	UIDropDownMenu_AddButton(info);
	for i=0, getn(ITEM_QUALITY_COLORS)  do
		info = {};
		info.text = getglobal("ITEM_QUALITY"..i.."_DESC");
		info.value = i;
		info.func = Udkp_BrowseDropDown_OnClick;
		UIDropDownMenu_AddButton(info);
	end

end

function Udkp_BrowseDropDown_OnClick()
	UIDropDownMenu_SetSelectedValue(Udkp_BrowseDropDown, this.value);
	UdkpOptions.ItemQuality = this.value;
end

function Udkp_ChannelDropDown_OnLoad()
 	UIDropDownMenu_Initialize(this, Udkp_Channel_Init);
	if(UdkpOptions.UdkpChannelLevel) then
		UIDropDownMenu_SetSelectedValue(this, UdkpOptions.UdkpChannelLevel);
	end
end

function Udkp_Channel_Init()
	info = {};
	info.text = UDKP_MESSAGE_CHANNEL_RAID;
	info.value = "RAID";
	info.func = Udkp_ChannelDropDown_OnClick;
	UIDropDownMenu_AddButton(info);
	
	info = {};
	info.text = UDKP_MESSAGE_CHANNEL_PARTY;
	info.value = "PARTY";
	info.func = Udkp_ChannelDropDown_OnClick;
	UIDropDownMenu_AddButton(info);
	
	info = {};
	info.text = UDKP_MESSAGE_CHANNEL_GUILD;
	info.value = "GUILD";
	info.func = Udkp_ChannelDropDown_OnClick;
	UIDropDownMenu_AddButton(info);
	
	info = {};
	info.text = UDKP_MESSAGE_CHANNEL_SAY;
	info.value = "SAY";
	info.func = Udkp_ChannelDropDown_OnClick;
	UIDropDownMenu_AddButton(info);
end

function Udkp_ChannelDropDown_OnClick()
	UIDropDownMenu_SetSelectedValue(Udkp_ChannelDropDown, this.value);
	UdkpOptions.UdkpChannelLevel = this.value;
end

function Udkp_RdkpDropDown_OnLoad()
 	UIDropDownMenu_Initialize(this, Udkp_Rdkp_Init);
	if(UdkpOptions.Rdkp) then
		UIDropDownMenu_SetSelectedValue(this, UdkpOptions.Rdkp);
	end
end

function Udkp_Rdkp_Init()
	info = {};
	info.text = UDKP_MESSAGE_RDKP_YES;
	info.value = 1;
	info.func = Udkp_RdkpDropDown_OnClick;
	UIDropDownMenu_AddButton(info);
	
	info = {};
	info.text = UDKP_MESSAGE_RDKP_NO;
	info.value = 0;
	info.func = Udkp_RdkpDropDown_OnClick;
	UIDropDownMenu_AddButton(info);
end

function Udkp_RdkpDropDown_OnClick()
	UIDropDownMenu_SetSelectedValue(Udkp_RdkpDropDown, this.value);
	UdkpOptions.Rdkp = this.value;
end